package com.jhd.fuzhou.util;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;

import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.jhd.fuzhou.R;
import com.jhd.fuzhou.view.photo.ChoosePhotoActivity;

public class ShowBottomDialog {
    /**
     * 显示拍照/从相册选取的底部对话框
     */
    public static void showBottomDialog(Context context,String supervisionType,String photoTemplateUrl) {
        Intent intent=new Intent(context, ChoosePhotoActivity.class);
        final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(context);
        View dialogView = LayoutInflater.from(context).inflate(R.layout.bsd_new_order, null);
        dialogView.findViewById(R.id.tv_take_photo).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (bottomSheetDialog != null) {
                    bottomSheetDialog.dismiss();
                }
                intent.putExtra("type","0");
                intent.putExtra("supervisionType",supervisionType);
                intent.putExtra("photoTemplateUrl",photoTemplateUrl);
                context.startActivity(intent);
            }
        });
        dialogView.findViewById(R.id.tv_select_gallery).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (bottomSheetDialog != null) {
                    bottomSheetDialog.dismiss();
                }
                intent.putExtra("type","1");
                intent.putExtra("supervisionType",supervisionType);
                intent.putExtra("photoTemplateUrl",photoTemplateUrl);
                context.startActivity(intent);
            }
        });
        dialogView.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (bottomSheetDialog != null) {
                    bottomSheetDialog.dismiss();
                }
            }
        });
        bottomSheetDialog.setContentView(dialogView);
        bottomSheetDialog.show();
    }

}
